package com.bytz.modules.cms.order.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bytz.modules.cms.order.constant.OfflinePayConstants;
import com.bytz.modules.cms.order.entity.OrderOfflinePay;
import com.bytz.modules.cms.order.mapper.OrderOfflinePayMapper;
import com.bytz.modules.cms.order.service.IMallOrderOfflinePayService;
import com.bytz.modules.cms.reseller.util.ResellerSecurityUtils;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

@Service
public class MallOrderOfflinePayServiceImpl extends ServiceImpl<OrderOfflinePayMapper, OrderOfflinePay> implements IMallOrderOfflinePayService {
    @Override
    public List<OrderOfflinePay> getByLoginUser() {

        String resellerId = ResellerSecurityUtils.getUserId();

        return lambdaQuery()
                .eq(OrderOfflinePay::getResellerId, resellerId)
                .eq(OrderOfflinePay::getStatus, OfflinePayConstants.OfflinePayStatus.AVAILABLE)
                .gt(OrderOfflinePay::getRemitAmount, BigDecimal.ZERO)
                .le(OrderOfflinePay::getEffectTime, LocalDateTime.now())
                .orderByDesc(OrderOfflinePay::getCreateTime)
                .list();
    }
}
